package view;
import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.JTextPane;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;


public class PurchaseOrderForm extends JPanel{
	private JTable table;
	public PurchaseOrderForm() {
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JSeparator separator = new JSeparator();
		springLayout.putConstraint(SpringLayout.WEST, separator, -10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, separator, -643, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.NORTH, separator, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, separator, 10, SpringLayout.WEST, this);
		add(separator);
		springLayout.putConstraint(SpringLayout.NORTH, separator, 159, SpringLayout.SOUTH, this);
		
		JTextPane textPane = new JTextPane();
		springLayout.putConstraint(SpringLayout.NORTH, textPane, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, textPane, 10, SpringLayout.WEST, this);
		add(textPane);
		
		JLabel lblOrderNodate = new JLabel("Order No./ Date:");
		springLayout.putConstraint(SpringLayout.WEST, lblOrderNodate, 297, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, textPane, -122, SpringLayout.WEST, lblOrderNodate);
		springLayout.putConstraint(SpringLayout.NORTH, lblOrderNodate, 10, SpringLayout.NORTH, this);
		add(lblOrderNodate);
		
		JLabel label = new JLabel("1/");
		springLayout.putConstraint(SpringLayout.NORTH, label, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, label, 17, SpringLayout.EAST, lblOrderNodate);
		add(label);
		
		JLabel lblQuotationNo = new JLabel("Quotation No. / Date :");
		springLayout.putConstraint(SpringLayout.NORTH, lblQuotationNo, 6, SpringLayout.SOUTH, lblOrderNodate);
		springLayout.putConstraint(SpringLayout.WEST, lblQuotationNo, 122, SpringLayout.EAST, textPane);
		add(lblQuotationNo);
		
		JLabel label_1 = new JLabel("2/");
		springLayout.putConstraint(SpringLayout.NORTH, label_1, 0, SpringLayout.NORTH, lblQuotationNo);
		springLayout.putConstraint(SpringLayout.WEST, label_1, 8, SpringLayout.EAST, lblQuotationNo);
		add(label_1);
		
		JLabel lblIndentNo = new JLabel("Indent No. / Date :");
		springLayout.putConstraint(SpringLayout.NORTH, lblIndentNo, 9, SpringLayout.SOUTH, lblQuotationNo);
		springLayout.putConstraint(SpringLayout.WEST, lblIndentNo, 122, SpringLayout.EAST, textPane);
		add(lblIndentNo);
		
		JLabel label_2 = new JLabel("121");
		springLayout.putConstraint(SpringLayout.WEST, label_2, 0, SpringLayout.WEST, label);
		springLayout.putConstraint(SpringLayout.SOUTH, label_2, 0, SpringLayout.SOUTH, lblIndentNo);
		add(label_2);
		
		JLabel lblProject = new JLabel("Project:");
		springLayout.putConstraint(SpringLayout.NORTH, lblProject, 0, SpringLayout.NORTH, lblIndentNo);
		add(lblProject);
		
		JComboBox comboBox = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, comboBox, -3, SpringLayout.NORTH, lblIndentNo);
		springLayout.putConstraint(SpringLayout.WEST, comboBox, 30, SpringLayout.EAST, lblProject);
		
		add(comboBox);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		springLayout.putConstraint(SpringLayout.NORTH, scrollPane_1, 119, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPane_1, -166, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.SOUTH, textPane, -24, SpringLayout.NORTH, scrollPane_1);
		springLayout.putConstraint(SpringLayout.WEST, scrollPane_1, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, scrollPane_1, -10, SpringLayout.EAST,this);
		add(scrollPane_1);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null, null, null},
			},
			new String[] {
				"Item Code ", "Description", "Specification / Size", "Unit", "Quantity", "Rate", "Discount", "Amount"
			}
		) {
			boolean[] columnEditables = new boolean[] {
				false, false, false, false, true, true, true, false
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(0).setPreferredWidth(67);
		table.getColumnModel().getColumn(2).setPreferredWidth(107);
		scrollPane_1.setViewportView(table);
		
		JLabel lblDestination = new JLabel("Destination:");
		springLayout.putConstraint(SpringLayout.WEST, lblDestination, 27, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, lblDestination, -177, SpringLayout.SOUTH, this);
		add(lblDestination);
		
		JComboBox comboBox_1 = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, comboBox_1, -3, SpringLayout.NORTH, lblDestination);
		springLayout.putConstraint(SpringLayout.WEST, comboBox_1, 47, SpringLayout.EAST, lblDestination);
		add(comboBox_1);
		
		JLabel lblInspection = new JLabel("Inspection:");
		springLayout.putConstraint(SpringLayout.WEST, lblInspection, 321, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, comboBox_1, -71, SpringLayout.WEST, lblInspection);
		springLayout.putConstraint(SpringLayout.NORTH, lblInspection, 0, SpringLayout.NORTH, lblDestination);
		add(lblInspection);
		
		JLabel lblCostCentre = new JLabel("Cost Centre:");
		springLayout.putConstraint(SpringLayout.WEST, lblProject, 0, SpringLayout.WEST, lblCostCentre);
		springLayout.putConstraint(SpringLayout.NORTH, lblCostCentre, 0, SpringLayout.NORTH, lblOrderNodate);
		springLayout.putConstraint(SpringLayout.WEST, lblCostCentre, 61, SpringLayout.EAST, label);
		add(lblCostCentre);
		
		JComboBox comboBox_6 = new JComboBox();
		springLayout.putConstraint(SpringLayout.EAST, comboBox_6, 0, SpringLayout.EAST, comboBox);
		springLayout.putConstraint(SpringLayout.NORTH, comboBox_6, 0, SpringLayout.NORTH, textPane);
		springLayout.putConstraint(SpringLayout.WEST, comboBox_6, 6, SpringLayout.EAST, lblCostCentre);
		add(comboBox_6);
	}
}
